package com.yunxi.module.infra.mapper.file;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunxi.framework.mybatis.core.mapper.BaseMapperX;
import com.yunxi.module.infra.model.file.FileContentDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * <p>
 * 文件内容 Mapper
 * </p>
 *
 * @author lidy
 * @since 2024-05-18
 */
@Mapper
public interface FileContentMapper extends BaseMapperX<FileContentDO> {

    /**
     * 根据配置ID和路径删除
     *
     * @param configId 配置ID
     * @param path     路径
     */
    default void deleteByConfigIdAndPath(Long configId, String path) {
        this.delete(new LambdaQueryWrapper<FileContentDO>()
                .eq(FileContentDO::getConfigId, configId)
                .eq(FileContentDO::getPath, path));
    }

    /**
     * 根据配置ID和路径查询
     *
     * @param configId 配置ID
     * @param path     路径
     * @return 集合
     */
    default List<FileContentDO> selectListByConfigIdAndPath(Long configId, String path) {
        return selectList(new LambdaQueryWrapper<FileContentDO>()
                .eq(FileContentDO::getConfigId, configId)
                .eq(FileContentDO::getPath, path));
    }


}
